-
Notifications
You must be signed in to change notification settings - Fork 51
feat(flags): Add retry support for feature flag requests #392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
9bb9617 to
4b16ae9
Compare
4b16ae9 to
687465b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8fb57c9 to
08687d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
08687d7 to
28c7e09
Compare
Use urllib3's built-in Retry mechanism for feature flag POST requests instead of application-level retry logic. This is simpler and leverages well-tested library code. Key changes: - Add `RETRY_STATUS_FORCELIST` = [408, 500, 502, 503, 504] - Add `_build_flags_session()` with POST retries and `status_forcelist` - Update `flags()` to use dedicated flags session - Add tests for retry configuration and session usage The flags session retries on: - Network failures (connect/read errors) - Transient server errors (408, 500, 502, 503, 504) It does NOT retry on: - 429 (rate limit) - need to wait, not hammer - 402 (quota limit) - won't resolve with retries
28c7e09 to
eba2bbd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, no comments
dc5bcad to
6e3ca18
Compare
dustinbyrne
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good - one comment about the network failures 👍
Add tests that verify actual retry behavior, not just configuration: - test_retries_on_503_then_succeeds: Spins up a local HTTP server that returns 503 twice then 200, verifying 3 requests are made - test_connection_errors_are_retried: Verifies connection errors trigger retries by measuring elapsed time with backoff Both tests use dynamically allocated ports for CI safety.
Problem
Feature flag requests can fail due to transient issues like read timeouts, connection errors, or temporary server problems. Currently these failures bubble up immediately without any retry attempt.
Example error:
Solution
Create a dedicated HTTP session for feature flag requests configured with urllib3's
Retry:This leverages urllib3's battle-tested retry logic rather than adding application-level retry code.
Why not retry 429?
Rate limits indicate the client should back off, not immediately retry. Retrying would make the problem worse.
Related
enable_keep_alive()) which addresses idle connection dropsExamples
I also updated example.py so it can run without a personal api key set. This allows testing the sdk against /flags.